<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use frontend\assets\AppAsset;
use common\widgets\Alert;
use yii\bootstrap\ActiveForm;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>

</head>
<body>
<?php $this->beginBody() ?>

    <?php
    NavBar::begin([
        'brandLabel' => '资源融合系统',
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
            'class' => 'navbar-inverse navbar-fixed-top',
        ],
    ]);
    $menuLeft = [
        ['label' => '首页', 'url' => ['/site/index']],
        ['label' => '标准图谱', 'url' => ['/normal/index']],
        ['label' => '公开图谱', 'url' => ['/site/contact']],
    ];
    if (Yii::$app->user->isGuest) {
        $menuItems[] = ['label' => '注册', 'url' => ['/site/signup']];
        $menuItems[] = ['label' => '登录', 'url' => ['/site/login']];
    } else {
        $menuItems[]=[
            'label' => '<img src="/knowMap/frontend/web/statics/css/icon/myimage.jpg" alt="'.Yii::$app->user->identity->username.'">',
            'url' => ['/site/loout'],
             'linkOptions'=>['class'=>'avatar'],
            'items'=>[
                //使用Font Awesome图标字体库和CSS框架
                ['label'=>'<i class="fa fa-sign-out"></i> 退出', 'url'=>['site/logout'],'linkOptions'=>['data-method'=>'post']],
                ['label'=>'个人中心', 'url'=>['user/index'],'linkOptions'=>['data-method'=>'post']]
            ],
            //font-awesome-4.4
//            'linkOptions'=>['data-method'=>'post']
            ];
//        $menuItems[] = '<li>'
//            . Html::beginForm(['/site/logout'], 'post')
//            . Html::submitButton(
//                '退出 (' . Yii::$app->user->identity->username . ')',
//                ['class' => 'btn btn-link']
//            )
//            . Html::endForm()
//            . '</li>';
    }
    $search[]='<div>'
            .Html::beginForm(['/site/search'],'post')
            .Html::dropDownList('学科', 'subject', [0=>'学科',1=>'数学',2=>'语文',3=>'物理'],['class'=>'navbar-nav','id'=>'my-menu'])
            .Html::dropDownList('年级', 'grade', [0=>'年级',1=>'一年级',2=>'二年级',3=>'三年级'],['class'=>'navbar-nav','id'=>'my-grade'])
            .Html::textInput('content','请输入内容',[ 'placeholder'=>'请输入搜索条件'])
            .Html::submitButton('<i class="icon-repeat"></i>搜索')
            .Html::endForm()
            .'</div>';
    echo Nav::widget([
        'options'=>['class'=>'navbar-form visible-lg-inline-block'],//navbar-form visible-lg-inline-block
        'items'=>$search,
    ]);
    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-left'],
        'items' => $menuLeft,
    ]);
    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'encodeLabels'=>false,
        'items' => $menuItems,
    ]);
    NavBar::end();
    ?>
    
    <div class="container">
        <?= Breadcrumbs::widget([
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        ]) ?>
        <?= Alert::widget() ?>
        <?= $content ?>
    </div>


<footer class="footer">
    <div class="container">
        <p class="pull-left">&copy; My Company <?= date('Y') ?></p>

        <p class="pull-right"><?= Yii::powered() ?></p>
    </div>
</footer>

<script src="./statics/js/jquery.js"></script>
<script src="./statics/js/jquery.fancyspinbox.js"></script>
<script>
$('#my-menu').fancyspinbox();
//var offsettop=$("#navbar-nav navbar-left nav").offset().top;
//$("#my-menu").css({position: "absolute",'top':offsettop+100,'left':0,'z-index':2});
$('#my-grade').fancyspinbox();
</script>
    
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
